class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int ret = 0;
        int minn=1e4+10;
        for (int i = 0; i < prices.size(); i++) {
            minn=min(prices[i],minn);
            ret=max(ret,prices[i]-minn);
        }
        return ret>0?ret:0;
    }
};
